<?php

use App\Http\Controllers\Api\AuthorizationsController;
use App\Http\Controllers\Api\ImagesController;
use App\Http\Controllers\Api\UsersController;
use Illuminate\Support\Facades\Route;

Route::prefix('v1')->name('api.v1.')->group(function () {

    Route::middleware('throttle:30,1')->group(function (){

        //普通登录
        Route::post('authorizations',[AuthorizationsController::class,'store'])->name('authorizations.store');

        //第三方登录
        Route::post('/oauth2/{oauth_type}/authorizations',[AuthorizationsController::class,'oauthStore'])
            ->where('oauth_type','wechat')->name('oauth2.authorizations.store');

    });


    Route::middleware('throttle:60,1')->group(function () {

        //获取用户信息
        Route::get('users/{user}',[UsersController::class,'show'])->name('users.show');


        Route::middleware('auth:api')->group(function () {
            //个人信息
            Route::get('users',[UsersController::class,'me'])->name('users.name');
            //编辑用户
            Route::put('users',[UsersController::class,'update'])->name('users.update');

            //上传图片
            Route::post('images',[ImagesController::class,'store'])->name('images.store');


        });

    });
});
